
package com.ami.kvm.jviewer.kvmpkts;

import com.ami.kvm.jviewer.Debug;
import java.net.Socket;
import java.nio.ByteBuffer;

public class NullReader implements KVMReader {
	private KVMClient m_client;
	private ByteBuffer m_nullBuf;
	private int m_nullIx;
	private int m_readCnt;
	private int m_readSz;
	private int m_numRead;

	public NullReader(KVMClient paramKVMClient) {
		this.m_client = paramKVMClient;
		this.m_nullBuf = ByteBuffer.allocate(262144);
	}

	public void initialize() {
		this.m_readSz = this.m_client.m_pktHdr.pktSize;
		this.m_numRead = this.m_client.m_pktHdr.status;
		this.m_nullIx = 0;
		this.m_readCnt = 0;
		this.m_nullBuf.position(0);
		this.m_nullBuf.limit(this.m_readSz);
		this.m_client.onStartReading();
	}

	public int read(Socket paramSocket) {
		try {
			byte[] arrayOfByte = new byte[this.m_nullBuf.remaining()];
			this.m_nullIx = this.m_client.read_data(paramSocket, arrayOfByte);
			this.m_nullBuf.put(arrayOfByte);
		} catch (Exception localException1) {
			Debug.out.println("CTRL_RDR ");
			Debug.out.println(localException1);
			return -1;
		}
		try {
			if (this.m_readSz <= this.m_nullIx) {
				this.m_readCnt += 1;

				if (this.m_numRead <= this.m_readCnt) {
					this.m_client.onStopReading();

					HeaderReader localHeaderReader = this.m_client.getHdrReader();
					localHeaderReader.initialize();
					this.m_client.setState(localHeaderReader);
				} else {
					this.m_nullIx = 0;
					this.m_nullBuf.position(0);
				}
			}
		} catch (Exception localException2) {
			Debug.out.println("CTRL_RDR[2]");
			Debug.out.println(localException2);
			return -2;
		}
		return 0;
	}
}

/*
 * Location:
 * D:\Users\tianlin\Downloads\JViewer.jar!\com\ami\kvm\jviewer\kvmpkts\
 * NullReader.class Java compiler version: 5 (49.0) JD-Core Version: 0.7.1
 */